home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 09, No. 05 (1988-05)(MicroSPARC)(Side A).zip / Nibble Volume 09, No. 05 (1988-05)(MicroSPARC)(Side A).po / REPRO.DIR.B.S < prev    next >
Text File  |  1996-12-24  |  18KB  |  657 lines

  1.           SBTL "ProDOS REPRO COMMAND"
  2. **************************
  3. *       REPRO.DIR        *
  4. *  ProDOS REPRO Command  *
  5. *     by Leh-Wen Yau     *
  6. *   Copyright (C) 1988   *
  7. *   By MicroSPARC, Inc.  *
  8. *   Concord, MA  01742   *
  9. * EDASM.SYSTEM Assembler *
  10. **************************
  11. *
  12. *
  13. COPYALL   EQU $8000
  14. COPY      EQU $8156 @ "Get FN1 info" heading of COPY.ALL
  15. * COPY.ALL addresses
  16. * Make sure these addresses are adjusted with future
  17. * enhancements of Sandy Mossberg's COPY.ALL Program
  18. *
  19. * General Equates
  20. *
  21. A1L       EQU $3C MOVE start
  22. A2L       EQU $3E MOVE end
  23. A4L       EQU $42 MOVE destination
  24. STREND    EQU $6D Bottom of free space
  25. FRETOP    EQU $6F Bottom of strings
  26. MEMSIZ    EQU $73 HIMEM
  27. INBUF     EQU $200 Input buffer
  28. FN1INFO   EQU $2EE File info buffer used in COPY
  29. KEY       EQU $C000 Keyboard input
  30. MOVE      EQU $FE2C Monitor move
  31. *
  32. * BI Global Page Equates
  33. *
  34. EXTRNCMD  EQU $BE06 External command
  35. XTRNADDR  EQU $BE50 External command execution
  36. XLEN      EQU $BE52 Command length minus one
  37. XCNUM     EQU $BE53 Command number (ext cmd=0)
  38. PBITS     EQU $BE54 Permitted parameter bits
  39. FBITS     EQU $BE56 Found parameter bits
  40. VPATH1    EQU $BE6C Pathname 1 buffer pointer
  41. VPATH2    EQU $BE6E Pathname 2 buffer pointer
  42. GOSYSTEM  EQU $BE70 Execute MLI call
  43. CRACESS   EQU $BEA3 CREATE access code
  44. CRFKIND   EQU $BEA7 CREATE storage type code
  45. SSGINFO   EQU $BEB4 FILE.INFO parameter count
  46. FIFILID   EQU $BEB8 FILE.INFO file type code
  47. FIMDATE   EQU $BEBE FILE.INFO modification date
  48. OSYSBUF   EQU $BECE OPEN buffer pointer
  49. OREFNUM   EQU $BED0 OPEN reference number
  50. RWREFNUM  EQU $BED6 READ/WRITE reference number
  51. RWDATA    EQU $BED7 READ/WRITE buffer pointer
  52. RWCOUNT   EQU $BED9 READ/WRITE number bytes to R/W
  53. CFREFNUM  EQU $BEDE CLOSE reference number
  54. GETBUFR   EQU $BEF5 Allocate buffer space
  55. FRBUFRS   EQU $BEF8 Free all buffer space
  56. *
  57. * ProDOS System Global Page
  58. *
  59. DEVADR31  EQU $BF16 Slot 3 drive 1 device driver address
  60. DEVADR32  EQU $BF26 Slot 3 drive 2 device driver address
  61. MACHID    EQU $BF98 Machine ID byte
  62. *
  63. * MLI calls
  64. *
  65. CREATE    EQU $C0 CREATE
  66. GFILINFO  EQU $C4 GET.FILE.INFO
  67. OPEN      EQU $C8 OPEN
  68. READ      EQU $CA READ
  69. CLOSE     EQU $CC CLOSE
  70. *
  71. * Zero Page Command Storage Equates
  72. *
  73. OFFSET    EQU $06 Offset for relocation
  74. DIR1REF   EQU $06 DIR1 reference number
  75. FILECNT   EQU $07 Directory block file entry counter
  76. BUFFPTR   EQU $08 Directory block buffer pointer
  77. SUBCMD    EQU $1E REPRO sub-command save
  78. FILEPTR   EQU $CE File entry pointer
  79. PTR1      EQU $EC Pointer
  80. PTR2      EQU $EE Pointer
  81. PTR3      EQU $F9 Pointer
  82. PTR4      EQU $FB Pointer
  83. *
  84.           LST GEN
  85.           MSB ON
  86.           ORG $7C00
  87. *
  88. *
  89. * INSTALLATION
  90. *
  91. * Save external command address before installing COPY.ALL
  92. *
  93.           LDY EXTRNCMD+1
  94.           LDA EXTRNCMD+2
  95.           STY OLDCMDADR
  96.           STA OLDCMDADR+1
  97. *
  98. * Install COPY.ALL
  99. *
  100.           JSR COPYALL Install COPY command
  101. *
  102. * Allocate buffer for REPRO command code
  103. *
  104.           LDA #<CMDEND-CMDPARSE Get desired # of pages
  105.           JSR GETBUFR
  106.           BCS NOBFERR Buffer allocation error
  107.           STA A4L+1 Destination MSB
  108.           PHA  Save starting address MSB
  109. *
  110. * Calculate offset between load and final address
  111. *
  112.           SEC
  113.           SBC #<CMDPARSE
  114.           STA OFFSET
  115. *
  116. * Relocate absolute internal references
  117. *
  118.           LDY #0
  119.           LDX #RELOCLEN
  120. RELOC     LDA RELOCTBL-1,X
  121.           STA PTR1+1
  122.           DEX
  123.           LDA RELOCTBL-1,X
  124.           STA PTR1
  125.           CLC
  126.           LDA (PTR1),Y
  127.           ADC OFFSET
  128.           STA (PTR1),Y
  129.           DEX
  130.           BNE RELOC
  131. *
  132. * Set link to next external command (or RTS)
  133. *
  134.           LDY EXTRNCMD+1
  135.           LDA EXTRNCMD+2
  136.           STY CMDLINK+1
  137.           STA CMDLINK+2
  138.           STA JSRCOPY+2 Also take care of JSR COPY address
  139. *
  140. * Move command code to final location
  141. *
  142.           LDY #>CMDPARSE
  143.           LDA #<CMDPARSE
  144.           STY A1L Start LSB
  145.           STA A1L+1 Start MSB
  146.           LDY #>CODEEND
  147.           LDA #<CODEEND
  148.           STY A2L End LSB
  149.           STA A2L+1 End MSB
  150.           LDY #0
  151.           STY A4L Destination LSB
  152.           JSR MOVE Y=0 for monitor move
  153. *
  154. * Point EXTRNCMD at command code and exit
  155. *
  156.           LDY #0
  157.           PLA  Restore starting address MSB
  158.           STY EXTRNCMD+1
  159.           STA EXTRNCMD+2
  160.           RTS
  161. *
  162. * Generate NO BUFFER AVAILABLE error
  163. *
  164. NOBFERR   LDA #$C
  165.           RTS
  166. *
  167. * Relocate table
  168. *
  169. RELOCTBL  DW reloc1+2
  170.           DW reloc2+1
  171.           DW reloc3+2
  172.           DW reloc4+2
  173.           DW reloc5+2
  174.           DW reloc6+1
  175.           DW reloc7+2
  176. RELOCLEN  EQU *-RELOCTBL
  177. *
  178. here      EQU >*
  179.           DS $100-here,$00 Force page boundary and fill with zero
  180. *
  181. * COMMAND PARSING
  182. *
  183. * Check for valid command
  184. *
  185. CMDPARSE  LDX #0
  186.           LDY #0
  187. CMDLOOP   LDA INBUF,X Get INBUF char
  188.           INX
  189.           CMP #$A0
  190.           BEQ CMDLOOP Ignore space char
  191.           AND #$DF Ensure upper case
  192. reloc1    EOR CMDTXT,Y
  193.           BNE INVALID REPRO command not found
  194.           INY
  195.           CPY #CMDLEN
  196.           BCC CMDLOOP Get another char
  197. *
  198. * Valid command found
  199. *
  200. * -> Determine if sub-command specified
  201. *
  202.           LDA #0 Initialize sub-command
  203.           STA SUBCMD
  204.           LDA INBUF,X
  205.           CMP #'# Looking for a pound sign
  206.           BNE SETXLEN Not found - no sub-command
  207.           INX
  208.           INY
  209.           LDA INBUF,X Get sub-command code
  210.           AND #$DF Ensure upper case
  211.           CMP #'S SCRATCHRAM sub-command?
  212.           BEQ CMDSYN1 Good sub-command
  213.           CMP #'D DEINSTALL sub-command?
  214.           BEQ CMDSYN1 Good sub-command
  215.           CMP #'B SCRATCHRAM and DEINSTALL sub-command?
  216.           BEQ CMDSYN1 Good sub-command
  217.           SEC  Signal syntax error
  218.           RTS  Return to BI
  219. CMDSYN1   STA SUBCMD Save sub-command
  220.           INX
  221.           INY
  222. *
  223. * -> Store length of command string minus one
  224. *
  225. SETXLEN   DEY
  226.           STY XLEN
  227. *
  228. * -> Flag external command
  229. *
  230.           LDA #0
  231.           STA XCNUM
  232. *
  233. * -> Set permitted parameter bits (PBITS/PBITS+1)
  234. *
  235.           STA PBITS+1 Allow no letter parameters
  236.           LDA #3
  237.           STA PBITS Allow DIR1 and DIR2
  238. *
  239. * -> Point BI at command execution code
  240. *
  241.           LDY #>CMDEXEC
  242. reloc2    LDA #<CMDEXEC
  243.           STY XTRNADDR
  244.           STA XTRNADDR+1
  245. *
  246. * Return control to BI
  247. *
  248.           CLC  Signal no error
  249.           RTS
  250. *
  251. * Valid command string not found
  252. *
  253. INVALID   SEC
  254. CMDLINK   JMP $0000 Link addr to external command
  255. *
  256. OLDCMDADR DW 0 External command addr before install COPY
  257. *
  258. * Text of REPRO command
  259. *
  260. CMDTXT    ASC "REPRO"
  261. CMDLEN    EQU *-CMDTXT
  262. *
  263. * COMMAND EXECUTION
  264. *
  265. * Check that both filenames given
  266. *
  267. CMDEXEC   LDA FBITS
  268.           LSR
  269.           BCC SYNERR DIR1 not found
  270.           LSR
  271.           BCC SYNERR DIR2 not found
  272. *
  273. * Check for sub-command to scratch /RAM disk
  274. *
  275.           LDA SUBCMD Check sub-command
  276.           CMP #'S Is SCRATCHRAM specified?
  277.           BEQ CKSUBCMD1 Yes - proceed
  278.           CMP #'B Both SCRATCHRAM and DEINSTALL specified?
  279.           BNE CKBUFR No - proceed
  280.           LDA #'D Set DEINSTALL sub-command for later
  281.           STA SUBCMD
  282. reloc3    EQU *
  283. CKSUBCMD1 JSR INITRAM Go initializing /RAM disk
  284. *
  285. * Check for at least 13 full pages of free space
  286. *
  287. CKBUFR    LDA FRETOP+1
  288.           SBC STREND+1
  289.           CMP #14
  290.           BCC NOBUFERR Not enough pages
  291.           LDY #0 Set directory buffer pointer
  292.           STY BUFFPTR in Zero Page
  293.           LDA STREND+1 Set file buffer above
  294.           CLC  buffer used by COPY command
  295.           ADC #8 6 pages reserved by COPY
  296.           STA BUFFPTR+1 1 page to store diretory pathnames
  297. *
  298. * Get DIR1 info
  299. *
  300.           LDA #$A Set GET.FILE.INFO
  301.           STA SSGINFO parameter count
  302.           LDA #GFILINFO
  303.           JSR GOSYSTEM GET.FILE.INFO call
  304.           BCS RTS1 Error
  305. *
  306. * Reject non-directory file
  307. *
  308.           LDA FIFILID
  309.           CMP #$F
  310.           BNE FTMISERR Not a directory file
  311. *
  312. * Set buffer pointer and save pathnames
  313. *
  314.           LDY BUFFPTR+1 Set directory pathname
  315.           DEY  save area pointer
  316.           STY PTR2+1
  317.           LDA VPATH1 Get source directory pathname pointer
  318.           LDY VPATH1+1
  319.           STA PTR1 Set it in Zero Page
  320.           STY PTR1+1
  321.           LDA #$80 Get source directory pathname buffer
  322. SAVEPATH  STA PTR2
  323.           LDY #0
  324.           LDA (PTR1),Y Get directory pathname length
  325.           TAY
  326. SAVE1     LDA (PTR1),Y Save directory pathname
  327.           STA (PTR2),Y
  328.           DEY
  329.           BPL SAVE1
  330.           LDA PTR2
  331.           CMP #$C0 Are we processing target directory?
  332.           BGE OPENDIR1 Yes - done!
  333.           LDA VPATH2 Get target directory pathname pointer
  334.           LDY VPATH2+1
  335.           STA PTR1
  336.           STY PTR1+1
  337.           LDA #$C0 Get target directory pathname savearea
  338.           BNE SAVEPATH (always) save it
  339. *
  340. * Generate SYNTAX ERROR
  341. *
  342. SYNERR    LDA #$10
  343.           DB $2C Skip next 2-byte instruction
  344. *
  345. * Generate FILE TYPE MISMATCH error
  346. *
  347. FTMISERR  LDA #$D
  348.           DB $2C Skip next 2 byte instruction
  349. *
  350. * Generate NO BUFFERS AVAILABLE error
  351. *
  352. NOBUFERR  LDA #$C
  353.           SEC
  354. RTS1      RTS
  355. *
  356. * Open DIR1 and save reference number
  357. *
  358. OPENDIR1  LDY BUFFPTR+1 Get directory buffer pointer
  359.           INY  Reserve 2 pages for R/W buffer
  360.           INY
  361.           STY OSYSBUF+1 Set file buffer
  362.           LDA #OPEN
  363.           JSR GOSYSTEM OPEN call
  364.           BCS RTS1 Error
  365.           LDA OREFNUM
  366.           STA DIR1REF Save DIR1 reference number
  367. *
  368. * Copy DIR2 to filename buffer pointed to in OPEN parmlist
  369. *
  370.           LDA VPATH1
  371.           STA PTR1 DIR1 pointer LSB
  372.           LDA VPATH1+1
  373.           STA PTR1+1 DIR1 pointer MSB
  374.           LDA VPATH2
  375.           STA PTR2 DIR2 pointer LSB
  376.           LDA VPATH2+1
  377.           STA PTR2+1 DIR2 pointer MSB
  378.           LDY #0
  379.           LDA (PTR2),Y Get length byte of DIR2
  380.           TAY
  381. p2        LDA (PTR2),Y Copy DIR2 to
  382.           STA (PTR1),Y DIR1 buffer
  383.           DEY
  384.           BPL p2
  385. *
  386. * Get DIR2 info
  387. *
  388.           LDA #GFILINFO
  389.           JSR GOSYSTEM GET.FILE.INFO call
  390.           BCS CKFNFERR Error, hopefully just a NOT FOUND
  391.           LDA FIFILID
  392.           CMP #$F
  393.           BNE FTMISERR Not a directory file
  394.           BEQ CKESC Target directory already exist
  395. *
  396. * Check fatal GET.FILE.INFO error
  397. *
  398. CKFNFERR  CMP #6 Report all errors except
  399.           BCC ERREXIT volume directory, pathname
  400.           CMP #7 or filename not found
  401.           BNE ERREXIT (BI error code 6,7)
  402. *
  403. * Create DIR2
  404. *
  405.           LDA #$C3 Ensure free access
  406.           STA CRACESS Set access code
  407.           LDA #$F Set file type code
  408.           STA CRACESS+1 to directory
  409.           LDA #$D Set storage type to
  410.           STA CRFKIND linked directory file
  411.           LDA #0 Zero out
  412.           STA CRACESS+2 auxiliary data
  413.           STA CRACESS+3
  414.           STA CRFKIND+1 date of creation
  415.           STA CRFKIND+2
  416.           STA CRFKIND+3 time of creation
  417.           STA CRFKIND+4
  418.           LDA #CREATE
  419.           JSR GOSYSTEM CREATE call (for DIR2)
  420.           BCS ERREXIT Error
  421.           BCC CKESC No error - proceed
  422. *
  423. * Close file(s) and generate error message
  424. *
  425. reloc4    EQU *
  426. ERREXIT   JSR CLOSEDIR
  427.           SEC
  428.           RTS
  429. *
  430. * Read directory block from DIR1 to R/W buffer
  431. *
  432. READDIR   LDA DIR1REF Set DIR1 reference number
  433.           STA RWREFNUM R/W parmlists
  434.           LDY #0
  435.           LDA BUFFPTR+1
  436.           STY RWDATA Set R/W buffer
  437.           STA RWDATA+1
  438.           LDA #2 Set # of bytes to be read
  439.           STA RWCOUNT+1 equal to 1 block ($200)
  440.           STY RWCOUNT
  441.           LDA #READ
  442.           JSR GOSYSTEM READ call
  443.           BCC CHECKDIR No error, examine directory block
  444.           CMP #5
  445.           BEQ ENDCOPY END OF DATA error so end
  446.           BNE ERREXIT Fatal error
  447. *
  448. * Allow abortion of copy with ESC key
  449. *
  450. CKESC     LDA KEY Get keystroke
  451.           BPL READDIR No key press - read directory
  452.           CMP #$9B If ESC pressed
  453.           BEQ ENDCOPY then end
  454.           BNE READDIR (always) Read directory block
  455. *
  456. * Copy completed so close files, set file into and exit
  457. *
  458. reloc5    EQU *
  459. ENDCOPY   JSR CLOSEDIR
  460.           LDA SUBCMD Check sub-command
  461.           CMP #'D Is DEINSTALL specified?
  462.           BNE RTS3 No - exit from REPRO command
  463.           LDY #>OLDCMDADR Restore old external command address
  464. reloc6    LDA #<OLDCMDADR back in BI
  465.           STY EXTRNCMD+1
  466.           STA EXTRNCMD+2
  467.           JSR FRBUFRS Free all acquired buffers
  468. RTS3      CLC  Tell BI there is no error
  469.           RTS  EXIT from REPRO command
  470. *
  471. * Process directory block
  472. *
  473. CHECKDIR  LDA #4 Initialize file entry pointer
  474.           STA FILEPTR
  475.           LDA BUFFPTR+1
  476.           STA FILEPTR+1
  477.           LDY #0 Check previous directory block #
  478.           STY FILECNT Initialize file counter
  479.           LDA (BUFFPTR),Y Low byte
  480.           INY
  481.           ORA (BUFFPTR),Y Now check high byte
  482.           BNE CHECKFILE Not first block
  483.           LDA #$2B First block - skip directory header
  484.           STA FILEPTR adjust file entry pointer
  485.           INC FILECNT Increment file entry counter
  486. *
  487. * Check file entries
  488. *
  489. CHECKFILE LDY #0
  490.           LDA (FILEPTR),Y Check file name length
  491.           CMP #$D0 High four bits $D?
  492.           BGE CHECK1 Yes - skip subdirectory file
  493.           CMP #$10 High four bits zero?
  494.           BLT CHECK1 Yes - skip inactive file
  495. reloc7    EQU *
  496. CHECK0    JSR COPYFILE Process file entry
  497.           BCC CHECK1 No error - proceed
  498.           CMP #$13 DUPLICATE FILE NAME?
  499.           BEQ CHECK3 Yes - proceed
  500.           BNE ERREXIT No - something bad happened, stop!
  501. CHECK1    LDA FILECNT
  502.           CMP #12 Last file entry?
  503.           BGE CHECK2 Yes - check for more directory block
  504.           INC FILECNT Increment file counter
  505.           CLC
  506.           LDA FILEPTR Bump up file pointer
  507.           ADC #$27
  508.           STA FILEPTR
  509.           LDA FILEPTR+1
  510.           ADC #0
  511.           STA FILEPTR+1
  512.           BNE CHECKFILE (always) Loop back
  513. CHECK2    LDY #2 Check next directory block number
  514.           LDA (BUFFPTR),Y Low byte
  515.           INY
  516.           ORA (BUFFPTR),Y Now check high byte
  517.           BNE CKESC More to go - proceed
  518.           BEQ ENDCOPY End of chain - all done!
  519. CHECK3    LDA FIFILID Compare file type
  520.           CMP FN1INFO+4
  521.           BNE CHECK1 Not the same, don't copy
  522.           LDA FIMDATE+1 Compare file modification date
  523.           CMP FN1INFO+11 (yyyyyyym)
  524.           BLT CHECK4 FN2 is older, replace it
  525.           BNE CHECK1 FN2 is newer, don't copy
  526.           LDA FIMDATE
  527.           CMP FN1INFO+10 (mmmddddd)
  528.           BLT CHECK4
  529.           BNE CHECK1
  530.           LDA FIMDATE+3 Compare file modification time
  531.           CMP FN1INFO+13 (hhhhhhhh)
  532.           BLT CHECK4
  533.           BNE CHECK1
  534.           LDA FIMDATE+2
  535.           CMP FN1INFO+12 (mmmmmmmm)
  536.           BLT CHECK4
  537.           BGE CHECK1
  538. CHECK4    LDA #$C1 DESTROY command code
  539.           JSR GOSYSTEM Scratch FN2
  540.           BCS CHECK1 Error - forget it
  541.           BCC CHECK0 Copy again
  542. *
  543. * Construct COPY command and copy file
  544. *
  545. COPYFILE  LDY BUFFPTR+1 Set source directory
  546.           DEY  pathname pointer
  547.           STY PTR1+1
  548.           STY PTR3+1 (take care of target directory too)
  549.           LDA #$80
  550.           STA PTR1
  551.           LDA VPATH1 Get BI source pathname buffer pointer
  552.           LDY VPATH1+1
  553.           STA PTR2
  554.           STY PTR2+1
  555.           LDY #0
  556.           LDA (PTR1),Y Get source directory pathname length
  557.           TAY
  558. COPY1     LDA (PTR1),Y Move source directory pathname
  559.           STA (PTR2),Y to BI source pathname buffer
  560.           DEY
  561.           BPL COPY1
  562.           LDA #$C0 Set target directory pathname pointer
  563.           STA PTR3
  564.           LDA VPATH2 Get BI target pathname buffer pointer
  565.           LDY VPATH2+1
  566.           STA PTR4
  567.           STY PTR4+1
  568.           LDY #0
  569.           LDA (PTR3),Y Get target directory pathname length
  570.           TAY
  571. COPY2     LDA (PTR3),Y Move target pathname length
  572.           STA (PTR4),Y to BI target pathname buffer
  573.           DEY
  574.           BPL COPY2
  575.           LDY #0
  576.           LDA (FILEPTR),Y Get file pathname length
  577.           AND #$0F Zero out high four bits
  578.           TAX  Save file pathname length
  579.           CLC  Adjust BI source pathname length
  580.           ADC (PTR1),Y
  581.           ADC #1 Add 1 for "/"
  582.           STA (PTR2),Y
  583.           TXA  Restore file pathname length
  584.           ADC (PTR3),Y Adjust BI target pathname length
  585.           ADC #1 Add 1 for "/"
  586.           STA (PTR4),Y
  587.           LDA (PTR1),Y Adjust BI source pathname buffer pointer
  588.           ADC PTR2
  589.           ADC #1 Add 1 for "/"
  590.           STA PTR2
  591.           LDA PTR2+1
  592.           ADC #0
  593.           STA PTR2+1
  594.           CLC  Adjust BI target pathname buffer pointer
  595.           LDA (PTR3),Y
  596.           ADC PTR4
  597.           ADC #1 Add 1 for "/"
  598.           STA PTR4
  599.           LDA PTR4+1
  600.           ADC #0
  601.           STA PTR4+1
  602.           TXA  Restore file pathname length
  603.           TAY
  604. COPY3     LDA (FILEPTR),Y Move file pathname
  605.           STA (PTR2),Y to BI source and target
  606.           STA (PTR4),Y pathname buffer
  607.           DEY
  608.           BNE COPY3
  609.           LDA #$2F "/"
  610.           STA (PTR2),Y End of directory pathname marker
  611.           STA (PTR4),Y for both source and target files
  612. JSRCOPY   JSR COPY Use COPY.ALL Program to copy the file!
  613.           RTS
  614. *
  615. * Close DIR1 (internal subroutine)
  616. *
  617. CLOSEDIR  PHA  Preserve entry A-reg
  618.           LDA DIR1REF
  619.           STA CFREFNUM Set DIR1 reference number
  620.           LDA #CLOSE
  621.           JSR GOSYSTEM CLOSE call (DIR1)
  622.           PLA  Restore entry A-reg
  623.           RTS
  624. *
  625. * Initialize /RAM disk
  626. *
  627. INITRAM   LDA MACHID Check machine ID byte
  628.           AND #$30 Isolate memory bits
  629.           CMP #$30 128K?
  630.           BNE INITRAM1 No - do nothing
  631.           LDA DEVADR32 Check if slot 3,
  632.           CMP DEVADR31 drive 1 and drive 2 are the same
  633.           BNE INITRAM2 No - /RAM disk installed
  634.           LDA DEVADR32+1
  635.           CMP DEVADR31+1
  636.           BNE INITRAM2
  637. INITRAM1  RTS
  638. INITRAM2  LDA #$B0 Slot 3, drive 2 (dsss0000)
  639.           STA $43
  640.           LDA #3 Command = FORMAT
  641.           STA $42
  642.           LDA #0 Use BI general purpose buffer
  643.           STA $44
  644.           LDA MEMSIZ+1
  645.           STA $45
  646.           STA $C080 Select language card for driver
  647.           JSR INITRAM3 Go format the volume
  648.           STA $C081 Select ROM
  649.           RTS
  650. INITRAM3  JMP (DEVADR32) Jump to /RAM driver
  651. *
  652. CODEEND   EQU *
  653. here2     EQU >*
  654.           DS $100-here2,$00 Force page boundary
  655. *
  656. CMDEND    EQU *
  657.